<?php
$str1 = "Mon premier cours commence aujourd'hui";
function longestWold($str)
{
	$count = 0;
	$max = 0;
	$max_position = 0;
	for ($i = 0; $i < strlen($str); ++$i) {
		if ($str[$i] != " ") {
			$count++;
		} else {
			if ($max < $count) {
				$max = $count;
			}
			$count = 0;
			$max_position++;
		}
	}
	if ($max < $count) {
		$max = $count;
		$count = 0;
		$max_position++;
	}
	return $max_position;
}

echo longestWold($str1);